package com.rui.sideup.module.redis.service;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "redis操作")
@RestController
@RequestMapping("/redis")
public class RedisController {

    @Autowired
    private RedisTemplate redisTemplate;

    @ApiOperation("set")
    @PostMapping("/set")
    public String set(String name) {
        redisTemplate.opsForValue().set("name", name);
        return name;
    }

    @ApiOperation("get")
    @GetMapping("/get")
    public Object get(String key) {
        Object obj = redisTemplate.opsForValue().get(key);
        return obj;
    }

}
